{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>如何加速Python代码?</td>\n",
       "      <td>Python 必须清理你创建的每个对象才能释放内存,这就是所谓的“垃圾回收”.许多未使用对象...</td>\n",
       "      <td>AI前线</td>\n",
       "      <td>1587360632</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:30:32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Python版的Gameboy模拟器,还能训练AI模型?</td>\n",
       "      <td>Python 访问,因此支持并鼓励人们做实验研究,机器人和人工智能在作此尝试.研究者正在构建...</td>\n",
       "      <td>Crossin的编程教室</td>\n",
       "      <td>1587361546</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:45:46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>关于 Python 命令中的 -m 参数</td>\n",
       "      <td>在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下...</td>\n",
       "      <td>Crossin的编程教室</td>\n",
       "      <td>1587361546</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:45:46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Python知识免费学!孩子提高逻辑思维,这样练就够了!</td>\n",
       "      <td>12岁以上建议报名小图灵Python课程.2.课前需要准备什么?错过直播怎么办?必须使用电脑...</td>\n",
       "      <td>教育那点事儿</td>\n",
       "      <td>1587393888</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 14:44:48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>python简介04:字典</td>\n",
       "      <td>之前我们介绍了列表list与元组tuple这两种数据结构,其中列表list是我们用的最基本的...</td>\n",
       "      <td>南方的言</td>\n",
       "      <td>1587382691</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 11:38:11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>python之创建list</td>\n",
       "      <td>list是python语言的一种内置的数据类型.list是数学意义上的有序集合,也就是说li...</td>\n",
       "      <td>Jazmine</td>\n",
       "      <td>1587371010</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 08:23:30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Python正则表达式,看这一篇就够了</td>\n",
       "      <td>Python中关于 正则表达式的函数.re模块主要定义了9个常量、12个函数、1个异常,每个...</td>\n",
       "      <td>AI科技大本营</td>\n",
       "      <td>1587379860</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 10:51:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Python 什么时候会被取代?</td>\n",
       "      <td>Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...</td>\n",
       "      <td>程序人生</td>\n",
       "      <td>1586417179</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-09 07:26:19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>确认!这样学习 Python 能甩同行 10 条街!</td>\n",
       "      <td>Python 将成为每个开发者的标配.作者 | GitChat头图 | CSDN 下载自 V...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1586520304</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-10 12:05:04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Python入门教程丨1300多行代码,让你轻松掌握基础知识点</td>\n",
       "      <td>前言本文适合有经验的程序员尽快进入Python世界.特别地,如果你掌握Java和Javasc...</td>\n",
       "      <td>python</td>\n",
       "      <td>1586347353</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-08 12:02:33</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                标题  \\\n",
       "0                    如何加速Python代码?   \n",
       "1     Python版的Gameboy模拟器,还能训练AI模型?   \n",
       "2             关于 Python 命令中的 -m 参数   \n",
       "3     Python知识免费学!孩子提高逻辑思维,这样练就够了!   \n",
       "4                    python简介04:字典   \n",
       "5                    python之创建list   \n",
       "6              Python正则表达式,看这一篇就够了   \n",
       "7                 Python 什么时候会被取代?   \n",
       "8       确认!这样学习 Python 能甩同行 10 条街!   \n",
       "9  Python入门教程丨1300多行代码,让你轻松掌握基础知识点   \n",
       "\n",
       "                                                  摘要        source  \\\n",
       "0  Python 必须清理你创建的每个对象才能释放内存,这就是所谓的“垃圾回收”.许多未使用对象...          AI前线   \n",
       "1  Python 访问,因此支持并鼓励人们做实验研究,机器人和人工智能在作此尝试.研究者正在构建...  Crossin的编程教室   \n",
       "2  在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下...  Crossin的编程教室   \n",
       "3  12岁以上建议报名小图灵Python课程.2.课前需要准备什么?错过直播怎么办?必须使用电脑...        教育那点事儿   \n",
       "4  之前我们介绍了列表list与元组tuple这两种数据结构,其中列表list是我们用的最基本的...          南方的言   \n",
       "5  list是python语言的一种内置的数据类型.list是数学意义上的有序集合,也就是说li...       Jazmine   \n",
       "6  Python中关于 正则表达式的函数.re模块主要定义了9个常量、12个函数、1个异常,每个...       AI科技大本营   \n",
       "7  Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...          程序人生   \n",
       "8  Python 将成为每个开发者的标配.作者 | GitChat头图 | CSDN 下载自 V...          CSDN   \n",
       "9  前言本文适合有经验的程序员尽快进入Python世界.特别地,如果你掌握Java和Javasc...        python   \n",
       "\n",
       "           时间                                              公众号链接  \\\n",
       "0  1587360632  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "1  1587361546  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "2  1587361546  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "3  1587393888  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "4  1587382691  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "5  1587371010  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "6  1587379860  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "7  1586417179  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "8  1586520304  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "9  1586347353  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "\n",
       "                                                文章链接                格式化时间  \n",
       "0  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:30:32  \n",
       "1  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:45:46  \n",
       "2  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:45:46  \n",
       "3  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 14:44:48  \n",
       "4  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 11:38:11  \n",
       "5  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 08:23:30  \n",
       "6  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 10:51:00  \n",
       "7  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-09 07:26:19  \n",
       "8  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-10 12:05:04  \n",
       "9  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-08 12:02:33  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# A-1 query 为关键字选取 以python为例\n",
    "import pandas as pd\n",
    "from requests_html import HTMLSession\n",
    "from pandas.api.types import is_numeric_dtype\n",
    "from pandas.io.json import json_normalize\n",
    "url = \"https://weixin.sogou.com/weixin\"\n",
    "session = HTMLSession()\n",
    "payload = {\n",
    "    \"query\":\"python\",\n",
    "    \"type\":\"2\", # 2 文章、1 公众号\n",
    "    \"page\":1  \n",
    "}\n",
    "\n",
    "r = session.get( url, params = payload, )\n",
    "\n",
    "\n",
    "主要元素 =  r.html.xpath( '//ul[@class=\"news-list\"]/li')\n",
    "\n",
    "dict_xpaths = {\n",
    "    'text':{\n",
    "        'source':'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/a/text()',\n",
    "        '时间':'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/@t',       \n",
    "    },\n",
    "    'text_content':{\n",
    "        '标题':'//div[contains(@class,\"txt-box\")]/h3/a',\n",
    "        '摘要':'//div[contains(@class,\"txt-box\")]/p'\n",
    "    },\n",
    "    'href':{\n",
    "        \"公众号链接\":'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/a/@href',\n",
    "        \"文章链接\":'//div[contains(@class,\"txt-box\")]/h3/a/@href',\n",
    "    }\n",
    "}\n",
    "\n",
    "\n",
    "def get_e_text_content(_xpath_):\n",
    "    # 高级列表推导\n",
    "    nlist= list()  #不能放在循环里面，因为如果放在里面，添加的数据就会被后面的替代，最后得到只是最后一个循环的数据，变量所放位置和返回数据的位置格外中重要\n",
    "    for e in 主要元素:\n",
    "        nlist.append(e.xpath(_xpath_)[0].lxml.text_content()) # .lxml.text_content(拼接标题)\n",
    "    return(nlist)\n",
    "#    暂存结果 = [e.xpath(_xpath_)[0].lxml.text_content() for e in 主要元素]\n",
    "#    return(暂存结果)\n",
    "\n",
    "def get_e_text(_xpath_):\n",
    "    nlist = list()\n",
    "    for e in 主要元素:\n",
    "        for x in e.xpath(_xpath_):\n",
    "            nlist.append(\"\".join([x.strip() if type(x) is str else x.text.strip()]))\n",
    "    return(nlist)\n",
    "#    暂存结果 = [\"\".join([x.strip() if type(x) is str else x.text.strip() for x in e.xpath(_xpath_)]) for e in 主要元素]\n",
    "#    return(暂存结果)\n",
    "\n",
    "def get_e_href(_xpath_):\n",
    "    # 高级列表推导\n",
    "    nlist=list()\n",
    "    for e in 主要元素:\n",
    "        for item in e.xpath(_xpath_):\n",
    "            nlist.append(\"https://weixin.sogou.com\"+item)\n",
    "    return(nlist)  #原来缩进决定了遍历第一个还是全部的内容，谨记！！\n",
    "#    暂存结果 = [\"https://weixin.sogou.com\"+item\\\n",
    "#            for item in e.xpath(_xpath_)\\\n",
    "#            for e in 主要元素]\n",
    "#    return(暂存结果)\n",
    "\n",
    "数据字典 = dict()\n",
    "# content\n",
    "for k,v in dict_xpaths['text_content'].items():\n",
    "    数据字典[k]=get_e_text_content(v)\n",
    "#    print(数据字典)\n",
    "#数据字典 = {k:get_e_text_content(v) for k,v in dict_xpaths['text_content'].items()}\n",
    "#print(数据字典)\n",
    "\n",
    "# text\n",
    "for k,v in dict_xpaths['text'].items():\n",
    "    数据字典[k]=get_e_text(v)\n",
    "#数据字典.update({k:get_e_text(v) for k,v in dict_xpaths['text'].items()})\n",
    "#print(数据字典)\n",
    "\n",
    "# href\n",
    "for k,v in dict_xpaths['href'].items():\n",
    "    数据字典[k]=get_e_href(v)\n",
    "#数据字典.update({k:get_e_href(v) for k,v in dict_xpaths['href'].items()})\n",
    "#print(数据字典)\n",
    "\n",
    "数据 = pd.DataFrame(数据字典)\n",
    "\n",
    "数据 = 数据.assign(\n",
    "    格式化时间 = lambda x: pd.to_datetime(x[\"时间\"], unit='s').dt.strftime('%Y-%m-%d %H:%M:%S')\n",
    ")\n",
    "数据\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['AI前线',\n",
       " 'Crossin的编程教室',\n",
       " 'Crossin的编程教室',\n",
       " '教育那点事儿',\n",
       " '南方的言',\n",
       " 'Jazmine',\n",
       " 'AI科技大本营',\n",
       " '程序人生',\n",
       " 'CSDN',\n",
       " 'python']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.html.xpath('//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/a/text()')\n",
    "##来源xpath\n",
    "#r.html.xpath('//div[@class=\"s-p\"]/a/text()')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['如何加速',\n",
       " '代码?',\n",
       " '版的Gameboy模拟器,还能训练AI模型?',\n",
       " '关于 ',\n",
       " ' 命令中的 -m 参数',\n",
       " '知识免费学!孩子提高逻辑思维,这样练就够了!',\n",
       " '简介04:字典',\n",
       " '之创建list',\n",
       " '正则表达式,看这一篇就够了',\n",
       " ' 什么时候会被取代?',\n",
       " '确认!这样学习 ',\n",
       " ' 能甩同行 10 条街!',\n",
       " '入门教程丨1300多行代码,让你轻松掌握基础知识点']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#标题\n",
    "a=r.html.xpath('//div[contains(@class,\"txt-box\")]/h3/a/text()')\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'如何加速Python代码?'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#完整标题\n",
    "r.html.xpath('//div[contains(@class,\"txt-box\")]/h3/a')[0].lxml.text_content()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Python 必须清理你创建的每个对象才能释放内存,这就是所谓的“垃圾回收”.许多未使用对象的垃圾回收会大大降低软件速度.尽...'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#简介\n",
    "r.html.xpath('//div[contains(@class,\"txt-box\")]/p')[0].lxml.text_content()\n",
    "#r.html.xpath('//div[contains(@class,\"txt-box\")]/p')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdz9hAFZHvOAvrB3fLsZY8_H3d-eeqBTdmCdFb_D0ExkjR0RWyTdsC9ffD6FLdcrCzfsv9agUQiWyD-fhItqiT8wrM6kkBAkqOu1qYWODvXOCrCtDVkPObK5qUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzM1N3sg6-MGMs4Ovzv0sOdV6iNSk94nbViiSSJhj5RDOB07es2XIcPyyXi_McJDQhaXt1_F979mkpTPofR_EpXMkiz4phah6JSZZ31x_ImfxrLH7J7jGXCqUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzM1N3sg6-MGMs4Ovzv0sOdV6iNSk94nbViiSSJhj5RDOB07es2XIcPyyXi_McJDQhaXt1_F979mkpTPofR_EpXMkiz4phah6JSZZ31x_ImfxrLH7J7jGXCqUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzm8v_vPQGNoDxM0PrhpThWcm62a7X6fMCWJls5iOw8XEnJzF3NCDwvl-PLobqeFZrQUXektIerUoX9qm4Vu8vAHadsLn_GICHYEEx49a0wqFPpHT6mjRU4OO00efWrWmm&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzlQCIubVzt3MvkEeH5UEgji3TGguOw4lg8KTPIx5DO4mMYAxfSMj1Zph7SE01eNr6q8lxw7oXEFT7ftrSHZlUs4rCSbw9La75Sb9coKdsAUgF_-npslbK6mRTpLLTNgHY&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzb2AvcLFS9mIjb5aelwKIsx6O1qUXSRPIcoBaidJrmk6zKBi7fJqweVYd4uGhb2kwVNGMgRVF9bdEkZnAIKHWmnVsYZlx40yKyMo10aikYp1-dXrtOmsAJqUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdz0Z4DBn4Zh0dhZ1RLwSLiLgu4t3bHnxkfGKRCJqwJ0Wxf-EelY8fdwft0vKg9oP5CgT3564Xworvnta86mt-GKEZ0wv0dyZvkH__rV_cKsXpjaRBGVIReP24OZCnxixtX&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzhiXxtXO9EWIxSPw0jjYSGEjnjJsf7swwALg6NXYasB9O7uNXIBeupB2XH4_Q6XnJSHQ4IkKSlqd-P580XxeujCM2S-X3VyEJsGmlUPTMe-qIcWKwZwZs724OZCnxixtX&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzeLxXplXAcuNuVuNPiFqscsKWDWntqkEi14zy27r5NbdFls1_OnGoFix4ZDKkBJOx-2Ls84MFeMX_AicIp_zOvGPUFDOlEptCCWHSCv1NEF1z9WS0gb8kDKUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n",
      "['https://weixin.sogou.com/weixin/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzKhkrIQmebKHlYhHkd3mspLTPGUm0OolGErK4Sq5xclsY1-mWDU6MeaOHX5_kBUMNCHXg-ceTOVHy5w8DevywTdIbJjZufLDJWmECrCmfbj9ES9upST72BeO00efWrWmm&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']\n"
     ]
    }
   ],
   "source": [
    "#公众号链接\n",
    "for item in r.html.xpath('//div[@class=\"s-p\"]/a/@href'):\n",
    "    a= list()\n",
    "    a.append('https://weixin.sogou.com/weixin'+item)\n",
    "    print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9sa9322q9iwoXlVogCNv9kdCTMhnIA5C6kO-j7GSNZusPmj_Ffg9QZ6iea3AurkGhsp3Y9gBxJ6AT_rFRfHR0sk6aPBFBDTMm_LphmC5c1Y748nQs1fmQSrHtuhpkRrZpuFWJ5A8aqMVRBPfVI4ZZ8sNozMkC6SfNGleGFEp-wYWq3X8EKMKOIA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPAlEi-XVqDJRFsV511DBFu_X-XOWR7A_Cu4YM-YuDrOpx_55JDHk3u2k-Y5JlrBFoEivHsUo6aCsrSyQef6x3ZQLPHvN2lcMCkYQ3poxk6Ey7y_onDx22sndrgozfSg6bw..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPGzavUQGKBYFsQuP6J8D081OV7Sl1W7W_WTfgvmDCfqr4_SwJGnIwxQ3ApZnGw4EiufZyVC0amj7Z3f5Pf7N-9TC4gG_y-YVQVE0RX1Irzo8sDgT48GZsE9hWLv6O878UA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd96dwhnbWU0yClHSlDOyUbbo2qNacVDPOSWoLcY0WBpOT6gQ5R0zBvweBv0A5TiDRe7VMCjKZiEPiaIQIj0cuL8FUdgn4bqa0r4Q__fe6d8c2mv_XWQzK-POZX8TkdJ-uxx9OhzkEQnh6W402BnwQPC6dZNJ-ZHwdGsvE612HXS1aTJmCU1UgHwQ..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9XMuNn5RgVH8r36t3LXSCZS2yJkDubNmfQGTreS1IGAeMjF4mBqH1_cCI8IfNb6Ibsr_V5qPFOozbjJcWKW2ltCRjQJlIyFh3RmZVIc5KRrZJH8Tt_MykGd1RlAz8rRuDIMcQ4-PWWNtXPx684gJBAuf4SWmuPfdPRZWainUfJVlCy6umSSPEsg..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9UsvmZKcSb2Yf9RZSY0uhDlB6zHV-tK1TewpXeXdKYuDXN-nz_USDbpBjxF5XH3UGTtqDN6neGmb8VCUk2SrGQoQE-r43ddF50lqv2UA0lABG3B8imjmxmzHeX0Xwte7fgvII_TebCWhk3CwBeGhW1CjSHrFCIAlKN4XZgOYIxF7y08OLTBhW0A..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9g8AsxrKPL2e7a0n0BlZE8KyYLXZjGDK6EpYI-xAU-9Z1mzGePdh3xmvQtXN9VPPo0xL425irIUP9QdiMLBQrP1dAgSnrzibcOVWZpzcLQ5oFxw-WZc6BMCS0xnfNWPh4-cVpu5taYXXEX37NLTuuib1yNaCtEoQp2_OfvWGqeJHFcvUoAZZH7Q..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9OPAbTa7ylcd6m6bjESu65yv8kd6Bdpw5P8-1ub1qZQ3pZQpkdkvpfYnmxv3jiN-3-4tRfK2qBlOKdJHMPX25Bg_fkYNr2PaVLggJ4DkXtiFjPhQvKBuoZMiemFtGwX5eBpOuBw2xtPTGXj9uH_-t6z3-gAnrBTK1rdydfEWUMt-fxjh3za6jWA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQcZfYjCRCQIl-Kz1UXTIiGNm8ddHOVX1PzDDg7u3jBGY647mACxQ_QQTs2Rhbh6d9zfnBBIlzEANXJJfs1Ypp9R7fjPZ0XdYwRCb1FD4cS3d3lnLPEfSBLh5LU3lqtPw9g..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A',\n",
       " '/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9guHGcmoYYXs4hL1GjGGGagVMTXK7aCKi0Ih7F7AMNW2Uh0xwJNF5bz8YKoh2pPEQMR-FvFergQVKq2ngJMm1t-mUVm9zTpTLEcIHJ0PnXov6aHEetb_bsHRYHOPL9XXE5CYeMBqm9s8g7HgXvEvsJhCFrA8fqoxkPFTQn1ZrqPWq3X8EKMKOIA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#文章链接\n",
    "r.html.xpath('//div[contains(@class,\"txt-box\")]/h3/a/@href')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1587360632',\n",
       " '1587361546',\n",
       " '1587361546',\n",
       " '1587393888',\n",
       " '1587382691',\n",
       " '1587371010',\n",
       " '1587379860',\n",
       " '1586417179',\n",
       " '1586520304',\n",
       " '1586347353']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#时间\n",
    "r.html.xpath('//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/@t')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/ZBjVrHIdkOlgXfGAj5iaCW6yA5xd5A7ZrvkZVRFWuo4dHNtBHMBzeU1icoGbXdnJ92EDCLic31ZhUeLKmMy5Qqo3Q/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/icic13vic5h8JH43IW2ahibM7HFvjEk4Lu0dyteH84E2ib7WLKp6b2ZiaI87FFSUDExkKOp1XHxiakLNgxGYibsNPIzaAg/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/icic13vic5h8JH43IW2ahibM7HFvjEk4Lu0dO6qczuIJxQib2BW5glTYrmx7vaUIZTETeQzojAJzmiaKicQz2iaopiawPkg/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/7YpooibE48iavSTficDZXsOG9kEzic0lYzOQgTxyJEU5mIwfpwibeMeAChvltmps2xEI5aIjiaiaYTgeEgpd1clicIwyhQ/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/1ciblPk6o2T5Rdcib7h0B2Gq3ialjqbQcWY0ibXibnbcp3U9ST1nca2JU8GvE0SKdcTR8QtCMAKcqG8JfAsHvbXXC9A/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/1ZQDvPIpQJTial93Cfx73eEurOuPLTibRHVT37aicD40LxQpfAwx73fypE5XLFTDBHYCUoHJyhic5NvmAhQaUJ37fw/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/BnSNEaficFAZ4B9UraicCrFxzBicib9UHNZ7gYRlrfxmbt4onMNNRBHIvJNhLX1Ivh4nBv1M1z3V5wYJ6sLZlib3lBA/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/1hReHaqafadv9X5FlXyW1LgiaAZ0zCdGGaicCZvK3UZWdmcrHPd9osDWicoe2JDcUaUel5eQjSLp4TAJpZCw779Tg/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/Pn4Sm0RsAugXrLIKYibw369F76vl6ESHvWZSHfnlujf9AgibZlpXFiaYVlV337YZicibtKp26TPpNQp6STUQiawibqgXA/0?wx_fmt=jpeg',\n",
       " '//img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_jpg/Kad3LZzM7n6wHzhopzZq1q58VI2hVLJ0pNiaqsIMvPHAwckBdYJyfMAF6yklvfSJ7vqazqPkf0b9qQZwKicbpWOw/0?wx_fmt=jpeg']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#图片\n",
    "#from IPython.core.display import display, Markdown \n",
    "r.html.xpath('//div[@class=\"img-box\"]/a/img/@src')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open (\"weixin_python.html\", encoding = \"utf8\", mode = \"w\") as fp:\n",
    "    fp.write(r.html.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdz9hAFZHvOAvrB3fLsZY8_H3d-eeqBTdmCdFb_D0ExkjR0RWyTdsC9ffD6FLdcrCzfsv9agUQiWyD-fhItqiT8wrM6kkBAkqOu1qYWODvXOCrCtDVkPObK5qUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzM1N3sg6-MGMs4Ovzv0sOdV6iNSk94nbViiSSJhj5RDOB07es2XIcPyyXi_McJDQhaXt1_F979mkpTPofR_EpXMkiz4phah6JSZZ31x_ImfxrLH7J7jGXCqUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzm8v_vPQGNoDxM0PrhpThWcm62a7X6fMCWJls5iOw8XEnJzF3NCDwvl-PLobqeFZrQUXektIerUoX9qm4Vu8vAHadsLn_GICHYEEx49a0wqFPpHT6mjRU4OO00efWrWmm&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzlQCIubVzt3MvkEeH5UEgji3TGguOw4lg8KTPIx5DO4mMYAxfSMj1Zph7SE01eNr6q8lxw7oXEFT7ftrSHZlUs4rCSbw9La75Sb9coKdsAUgF_-npslbK6mRTpLLTNgHY&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzb2AvcLFS9mIjb5aelwKIsx6O1qUXSRPIcoBaidJrmk6zKBi7fJqweVYd4uGhb2kwVNGMgRVF9bdEkZnAIKHWmnVsYZlx40yKyMo10aikYp1-dXrtOmsAJqUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdz0Z4DBn4Zh0dhZ1RLwSLiLgu4t3bHnxkfGKRCJqwJ0Wxf-EelY8fdwft0vKg9oP5CgT3564Xworvnta86mt-GKEZ0wv0dyZvkH__rV_cKsXpjaRBGVIReP24OZCnxixtX&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzhiXxtXO9EWIxSPw0jjYSGEjnjJsf7swwALg6NXYasB9O7uNXIBeupB2XH4_Q6XnJSHQ4IkKSlqd-P580XxeujCM2S-X3VyEJsGmlUPTMe-qIcWKwZwZs724OZCnxixtX&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzeLxXplXAcuNuVuNPiFqscsKWDWntqkEi14zy27r5NbdFls1_OnGoFix4ZDKkBJOx-2Ls84MFeMX_AicIp_zOvGPUFDOlEptCCWHSCv1NEF1z9WS0gb8kDKUiiWOv1GPM&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPvoKX-GWHQ1ngwvDqyjOWdzKhkrIQmebKHlYhHkd3mspLTPGUm0OolGErK4Sq5xclsY1-mWDU6MeaOHX5_kBUMNCHXg-ceTOVHy5w8DevywTdIbJjZufLDJWmECrCmfbj9ES9upST72BeO00efWrWmm&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9sa9322q9iwoXlVogCNv9kdCTMhnIA5C6kO-j7GSNZusPmj_Ffg9QZ6iea3AurkGhsp3Y9gBxJ6AT_rFRfHR0sk6aPBFBDTMm_LphmC5c1Y748nQs1fmQSrHtuhpkRrZpuFWJ5A8aqMVRBPfVI4ZZ8sNozMkC6SfNGleGFEp-wYWq3X8EKMKOIA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPAlEi-XVqDJRFsV511DBFu_X-XOWR7A_Cu4YM-YuDrOpx_55JDHk3u2k-Y5JlrBFoEivHsUo6aCsrSyQef6x3ZQLPHvN2lcMCkYQ3poxk6Ey7y_onDx22sndrgozfSg6bw..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPGzavUQGKBYFsQuP6J8D081OV7Sl1W7W_WTfgvmDCfqr4_SwJGnIwxQ3ApZnGw4EiufZyVC0amj7Z3f5Pf7N-9TC4gG_y-YVQVE0RX1Irzo8sDgT48GZsE9hWLv6O878UA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd96dwhnbWU0yClHSlDOyUbbo2qNacVDPOSWoLcY0WBpOT6gQ5R0zBvweBv0A5TiDRe7VMCjKZiEPiaIQIj0cuL8FUdgn4bqa0r4Q__fe6d8c2mv_XWQzK-POZX8TkdJ-uxx9OhzkEQnh6W402BnwQPC6dZNJ-ZHwdGsvE612HXS1aTJmCU1UgHwQ..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9XMuNn5RgVH8r36t3LXSCZS2yJkDubNmfQGTreS1IGAeMjF4mBqH1_cCI8IfNb6Ibsr_V5qPFOozbjJcWKW2ltCRjQJlIyFh3RmZVIc5KRrZJH8Tt_MykGd1RlAz8rRuDIMcQ4-PWWNtXPx684gJBAuf4SWmuPfdPRZWainUfJVlCy6umSSPEsg..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9UsvmZKcSb2Yf9RZSY0uhDlB6zHV-tK1TewpXeXdKYuDXN-nz_USDbpBjxF5XH3UGTtqDN6neGmb8VCUk2SrGQoQE-r43ddF50lqv2UA0lABG3B8imjmxmzHeX0Xwte7fgvII_TebCWhk3CwBeGhW1CjSHrFCIAlKN4XZgOYIxF7y08OLTBhW0A..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9g8AsxrKPL2e7a0n0BlZE8KyYLXZjGDK6EpYI-xAU-9Z1mzGePdh3xmvQtXN9VPPo0xL425irIUP9QdiMLBQrP1dAgSnrzibcOVWZpzcLQ5oFxw-WZc6BMCS0xnfNWPh4-cVpu5taYXXEX37NLTuuib1yNaCtEoQp2_OfvWGqeJHFcvUoAZZH7Q..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9OPAbTa7ylcd6m6bjESu65yv8kd6Bdpw5P8-1ub1qZQ3pZQpkdkvpfYnmxv3jiN-3-4tRfK2qBlOKdJHMPX25Bg_fkYNr2PaVLggJ4DkXtiFjPhQvKBuoZMiemFtGwX5eBpOuBw2xtPTGXj9uH_-t6z3-gAnrBTK1rdydfEWUMt-fxjh3za6jWA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQcZfYjCRCQIl-Kz1UXTIiGNm8ddHOVX1PzDDg7u3jBGY647mACxQ_QQTs2Rhbh6d9zfnBBIlzEANXJJfs1Ypp9R7fjPZ0XdYwRCb1FD4cS3d3lnLPEfSBLh5LU3lqtPw9g..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkj9JeTnkoGr0A4gV8M3bpyKVqXa8Fplpd9guHGcmoYYXs4hL1GjGGGagVMTXK7aCKi0Ih7F7AMNW2Uh0xwJNF5bz8YKoh2pPEQMR-FvFergQVKq2ngJMm1t-mUVm9zTpTLEcIHJ0PnXov6aHEetb_bsHRYHOPL9XXE5CYeMBqm9s8g7HgXvEvsJhCFrA8fqoxkPFTQn1ZrqPWq3X8EKMKOIA..&type=2&query=python&token=3AF68A2DD844171D6A6FC8D1731300FD6B6903905E9DB80A' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n"
     ]
    }
   ],
   "source": [
    "数据.to_excel(\"web_week05_sougou_weixin.xlsx\", sheet_name=\"搜查结果\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[<Element 'a' href='?query=python&type=2&page=2&ie=utf8' id='sogou_page_2' uigs='page_2'>, <Element 'a' href='?query=python&type=2&page=3&ie=utf8' id='sogou_page_3' uigs='page_3'>, <Element 'a' href='?query=python&type=2&page=4&ie=utf8' id='sogou_page_4' uigs='page_4'>, <Element 'a' href='?query=python&type=2&page=5&ie=utf8' id='sogou_page_5' uigs='page_5'>, <Element 'a' href='?query=python&type=2&page=6&ie=utf8' id='sogou_page_6' uigs='page_6'>, <Element 'a' href='?query=python&type=2&page=7&ie=utf8' id='sogou_page_7' uigs='page_7'>, <Element 'a' href='?query=python&type=2&page=8&ie=utf8' id='sogou_page_8' uigs='page_8'>, <Element 'a' href='?query=python&type=2&page=9&ie=utf8' id='sogou_page_9' uigs='page_9'>, <Element 'a' href='?query=python&type=2&page=10&ie=utf8' id='sogou_page_10' uigs='page_10'>, <Element 'a' class=('np',) href='?query=python&type=2&page=2&ie=utf8' id='sogou_next' uigs='page_next'>]\n"
     ]
    }
   ],
   "source": [
    "#解析翻页链接\n",
    "url = \"https://weixin.sogou.com/weixin\"\n",
    "session = HTMLSession()\n",
    "payload = {\n",
    "    \"query\":\"python\",\n",
    "    \"type\":\"2\"\n",
    "}\n",
    "r = session.get( url, params = payload)\n",
    "\n",
    "#翻页链接\n",
    "xpath_a = r.html.xpath('//div[@class=\"p-fy\"]/a')\n",
    "print (xpath_a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['?query=python&type=2&page=2&ie=utf8', '?query=python&type=2&page=3&ie=utf8', '?query=python&type=2&page=4&ie=utf8', '?query=python&type=2&page=5&ie=utf8', '?query=python&type=2&page=6&ie=utf8', '?query=python&type=2&page=7&ie=utf8', '?query=python&type=2&page=8&ie=utf8', '?query=python&type=2&page=9&ie=utf8', '?query=python&type=2&page=10&ie=utf8', '?query=python&type=2&page=2&ie=utf8']\n",
      "{'2': '?query=python&type=2&page=2&ie=utf8', '3': '?query=python&type=2&page=3&ie=utf8', '4': '?query=python&type=2&page=4&ie=utf8', '5': '?query=python&type=2&page=5&ie=utf8', '6': '?query=python&type=2&page=6&ie=utf8', '7': '?query=python&type=2&page=7&ie=utf8', '8': '?query=python&type=2&page=8&ie=utf8', '9': '?query=python&type=2&page=9&ie=utf8', '10': '?query=python&type=2&page=10&ie=utf8', '下一页': '?query=python&type=2&page=2&ie=utf8'}\n"
     ]
    }
   ],
   "source": [
    "#将href存为列表\n",
    "href_list=list()\n",
    "for x in xpath_a:\n",
    "    href_list.append(x.xpath('//@href')[0])\n",
    "print(href_list)\n",
    "#href_列表 = [x.xpath('//@href')[0] for x in r.html.xpath(xpath_翻页a)]\n",
    "#print (href_列表)\n",
    "\n",
    "#href_字典 = {x.text:x.xpath('//@href')[0]  for x in r.html.xpath(xpath_翻页a)}\n",
    "#print (href_字典)\n",
    "# 将href存为字典\n",
    "href_dict = dict()\n",
    "for x in xpath_a:  \n",
    "    href_dict[x.text]=x.xpath('//@href')[0]\n",
    "print(href_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'query': ['python'], 'type': ['2'], 'page': ['2'], 'ie': ['utf8']}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from urllib.parse import urlparse, parse_qs\n",
    "parse_qs(\"query=python&type=2&page=2&ie=utf8\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>scheme</th>\n",
       "      <th>netloc</th>\n",
       "      <th>path</th>\n",
       "      <th>params</th>\n",
       "      <th>query</th>\n",
       "      <th>fragment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=2&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=3&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=4&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=5&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=6&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=7&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=8&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=9&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=10&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>query=python&amp;type=2&amp;page=2&amp;ie=utf8</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  scheme netloc path params                                query fragment\n",
       "0                             query=python&type=2&page=2&ie=utf8         \n",
       "1                             query=python&type=2&page=3&ie=utf8         \n",
       "2                             query=python&type=2&page=4&ie=utf8         \n",
       "3                             query=python&type=2&page=5&ie=utf8         \n",
       "4                             query=python&type=2&page=6&ie=utf8         \n",
       "5                             query=python&type=2&page=7&ie=utf8         \n",
       "6                             query=python&type=2&page=8&ie=utf8         \n",
       "7                             query=python&type=2&page=9&ie=utf8         \n",
       "8                            query=python&type=2&page=10&ie=utf8         \n",
       "9                             query=python&type=2&page=2&ie=utf8         "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "scheme      1\n",
      "netloc      1\n",
      "path        1\n",
      "params      1\n",
      "query       9\n",
      "fragment    1\n",
      "dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ie</th>\n",
       "      <th>page</th>\n",
       "      <th>query</th>\n",
       "      <th>type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>utf8</td>\n",
       "      <td>2</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>utf8</td>\n",
       "      <td>3</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>utf8</td>\n",
       "      <td>4</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>utf8</td>\n",
       "      <td>5</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>utf8</td>\n",
       "      <td>6</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>utf8</td>\n",
       "      <td>7</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>utf8</td>\n",
       "      <td>8</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>utf8</td>\n",
       "      <td>9</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>utf8</td>\n",
       "      <td>10</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>utf8</td>\n",
       "      <td>2</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     ie page   query type\n",
       "0  utf8    2  python    2\n",
       "1  utf8    3  python    2\n",
       "2  utf8    4  python    2\n",
       "3  utf8    5  python    2\n",
       "4  utf8    6  python    2\n",
       "5  utf8    7  python    2\n",
       "6  utf8    8  python    2\n",
       "7  utf8    9  python    2\n",
       "8  utf8   10  python    2\n",
       "9  utf8    2  python    2"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ie       1\n",
      "page     9\n",
      "query    1\n",
      "type     1\n",
      "dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ie</th>\n",
       "      <th>page</th>\n",
       "      <th>query</th>\n",
       "      <th>type</th>\n",
       "      <th>page_int</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>utf8</td>\n",
       "      <td>2</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>utf8</td>\n",
       "      <td>3</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>utf8</td>\n",
       "      <td>4</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>utf8</td>\n",
       "      <td>5</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>utf8</td>\n",
       "      <td>6</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>utf8</td>\n",
       "      <td>7</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>utf8</td>\n",
       "      <td>8</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>utf8</td>\n",
       "      <td>9</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>utf8</td>\n",
       "      <td>10</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>utf8</td>\n",
       "      <td>2</td>\n",
       "      <td>python</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     ie page   query type  page_int\n",
       "0  utf8    2  python    2         2\n",
       "1  utf8    3  python    2         3\n",
       "2  utf8    4  python    2         4\n",
       "3  utf8    5  python    2         5\n",
       "4  utf8    6  python    2         6\n",
       "5  utf8    7  python    2         7\n",
       "6  utf8    8  python    2         8\n",
       "7  utf8    9  python    2         9\n",
       "8  utf8   10  python    2        10\n",
       "9  utf8    2  python    2         2"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# A-2 建构参数模板：找到关键参数及参数结构\n",
    "\n",
    "# 需要模组库\n",
    "from urllib.parse import urlparse, parse_qs\n",
    "import pandas as pd\n",
    "from IPython.display import display, HTML\n",
    "\n",
    "\n",
    "#df = pd.DataFrame([ urlparse(x) for x in href_list])  可拆成下面几行代码\n",
    "xlist = list()\n",
    "for x in href_list:\n",
    "    xlist.append(urlparse(x))\n",
    "df =pd.DataFrame(xlist)\n",
    "\n",
    "df_qs = pd.DataFrame([{k:v[0] for k,v in parse_qs(x).items()} for x in df['query'] ])\n",
    "\n",
    "\n",
    "display(df)\n",
    "print(df.nunique())\n",
    "display(df_qs)\n",
    "print(df_qs.nunique())\n",
    "\n",
    "df_qs.page\n",
    "df_qs = df_qs.assign (page_int=df_qs.page.astype(int)) # 变成整数(数值)\n",
    "display(df_qs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'query': ['python'], 'type': ['2'], 'page': ['5'], 'ie': ['utf8']}\n",
      "{'2': '?query=python&type=2&page=2&ie=utf8', '3': '?query=python&type=2&page=3&ie=utf8', '4': '?query=python&type=2&page=4&ie=utf8', '5': '?query=python&type=2&page=5&ie=utf8', '6': '?query=python&type=2&page=6&ie=utf8', '7': '?query=python&type=2&page=7&ie=utf8', '8': '?query=python&type=2&page=8&ie=utf8', '9': '?query=python&type=2&page=9&ie=utf8', '10': '?query=python&type=2&page=10&ie=utf8', '下一页': '?query=python&type=2&page=2&ie=utf8'}\n"
     ]
    }
   ],
   "source": [
    "# A-2 建构参数模板：找到关键参数及参数结构\n",
    "\n",
    "def parse_url_qs_for_page (url):\n",
    "    six_parts = urlparse(url) \n",
    "    out = parse_qs(six_parts.query)\n",
    "    return (out)\n",
    "\n",
    "# 取一例做模板\n",
    "\n",
    "参数模板 = parse_url_qs_for_page(href_list[3])\n",
    "print (参数模板)\n",
    "\n",
    "# 重新审视：href_字典\n",
    "print (href_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "10\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{1: {'query': ['python'], 'type': ['2'], 'page': [1], 'ie': ['utf8']},\n",
       " 2: {'query': ['python'], 'type': ['2'], 'page': [2], 'ie': ['utf8']},\n",
       " 3: {'query': ['python'], 'type': ['2'], 'page': [3], 'ie': ['utf8']},\n",
       " 4: {'query': ['python'], 'type': ['2'], 'page': [4], 'ie': ['utf8']},\n",
       " 5: {'query': ['python'], 'type': ['2'], 'page': [5], 'ie': ['utf8']},\n",
       " 6: {'query': ['python'], 'type': ['2'], 'page': [6], 'ie': ['utf8']},\n",
       " 7: {'query': ['python'], 'type': ['2'], 'page': [7], 'ie': ['utf8']},\n",
       " 8: {'query': ['python'], 'type': ['2'], 'page': [8], 'ie': ['utf8']},\n",
       " 9: {'query': ['python'], 'type': ['2'], 'page': [9], 'ie': ['utf8']},\n",
       " 10: {'query': ['python'], 'type': ['2'], 'page': [10], 'ie': ['utf8']}}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# A-3 建构参数模板生成器：query（搜索关键字）page\n",
    "def 参数模板生成(query, page):\n",
    "    参数 = 参数模板.copy()\n",
    "    参数['page'] = page\n",
    "    参数['query'] = query\n",
    "    return (参数)\n",
    "\n",
    "# -----------    参数模版生成器 目的 构建payload\n",
    "# payload={\n",
    "    \n",
    "# }\n",
    "\"\"\"\n",
    "参数_query_用户体验_page = { \n",
    "    i:参数模板生成(page = [i], \\\n",
    "                  query = ['用户体验']) \\\n",
    "    for i,v in href_dict.items()\\\n",
    "    }\n",
    "\"\"\"\n",
    "参数_query_python_page={i:参数模板生成(page=[i],query=['python']) for i,v in href_dict.items()}  #上面几行代码可合成这一行代码\n",
    "\n",
    "print (df_qs.page_int.min()) # 最小值只有2 1的时候没有链接？\n",
    "print (df_qs.page_int.max()) # 最大值只有9\n",
    "\"\"\"\n",
    "参数_query_python_page = { \n",
    "    i:参数模板生成(page = [i], \\\n",
    "                  query = ['python']) \\\n",
    "    for i in range(df_qs.page_int.min()-1,df_qs.page_int.max()+1)\\\n",
    "    }\n",
    "\"\"\"\n",
    "参数_query_python_page={i:参数模板生成(page = [i],query=['python']) for i in range(df_qs.page_int.min()-1,df_qs.page_int.max()+1)}\n",
    "参数_query_python_page"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 1 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 1}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 1 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>如何加速Python代码?</td>\n",
       "      <td>Python 必须清理你创建的每个对象才能释放内存,这就是所谓的“垃圾回收”.许多未使用对象...</td>\n",
       "      <td>AI前线</td>\n",
       "      <td>1587360632</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:30:32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Python版的Gameboy模拟器,还能训练AI模型?</td>\n",
       "      <td>Python 访问,因此支持并鼓励人们做实验研究,机器人和人工智能在作此尝试.研究者正在构建...</td>\n",
       "      <td>Crossin的编程教室</td>\n",
       "      <td>1587361546</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:45:46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>关于 Python 命令中的 -m 参数</td>\n",
       "      <td>在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下...</td>\n",
       "      <td>Crossin的编程教室</td>\n",
       "      <td>1587361546</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 05:45:46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Python知识免费学!孩子提高逻辑思维,这样练就够了!</td>\n",
       "      <td>12岁以上建议报名小图灵Python课程.2.课前需要准备什么?错过直播怎么办?必须使用电脑...</td>\n",
       "      <td>教育那点事儿</td>\n",
       "      <td>1587393888</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 14:44:48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>python简介04:字典</td>\n",
       "      <td>之前我们介绍了列表list与元组tuple这两种数据结构,其中列表list是我们用的最基本的...</td>\n",
       "      <td>南方的言</td>\n",
       "      <td>1587382691</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 11:38:11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>python之创建list</td>\n",
       "      <td>list是python语言的一种内置的数据类型.list是数学意义上的有序集合,也就是说li...</td>\n",
       "      <td>Jazmine</td>\n",
       "      <td>1587371010</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 08:23:30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Python正则表达式,看这一篇就够了</td>\n",
       "      <td>Python中关于 正则表达式的函数.re模块主要定义了9个常量、12个函数、1个异常,每个...</td>\n",
       "      <td>AI科技大本营</td>\n",
       "      <td>1587379860</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-20 10:51:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Python 什么时候会被取代?</td>\n",
       "      <td>Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...</td>\n",
       "      <td>程序人生</td>\n",
       "      <td>1586417179</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-09 07:26:19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>确认!这样学习 Python 能甩同行 10 条街!</td>\n",
       "      <td>Python 将成为每个开发者的标配.作者 | GitChat头图 | CSDN 下载自 V...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1586520304</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-10 12:05:04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Python入门教程丨1300多行代码,让你轻松掌握基础知识点</td>\n",
       "      <td>前言本文适合有经验的程序员尽快进入Python世界.特别地,如果你掌握Java和Javasc...</td>\n",
       "      <td>python</td>\n",
       "      <td>1586347353</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-08 12:02:33</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                标题  \\\n",
       "0                    如何加速Python代码?   \n",
       "1     Python版的Gameboy模拟器,还能训练AI模型?   \n",
       "2             关于 Python 命令中的 -m 参数   \n",
       "3     Python知识免费学!孩子提高逻辑思维,这样练就够了!   \n",
       "4                    python简介04:字典   \n",
       "5                    python之创建list   \n",
       "6              Python正则表达式,看这一篇就够了   \n",
       "7                 Python 什么时候会被取代?   \n",
       "8       确认!这样学习 Python 能甩同行 10 条街!   \n",
       "9  Python入门教程丨1300多行代码,让你轻松掌握基础知识点   \n",
       "\n",
       "                                                  摘要        source  \\\n",
       "0  Python 必须清理你创建的每个对象才能释放内存,这就是所谓的“垃圾回收”.许多未使用对象...          AI前线   \n",
       "1  Python 访问,因此支持并鼓励人们做实验研究,机器人和人工智能在作此尝试.研究者正在构建...  Crossin的编程教室   \n",
       "2  在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下...  Crossin的编程教室   \n",
       "3  12岁以上建议报名小图灵Python课程.2.课前需要准备什么?错过直播怎么办?必须使用电脑...        教育那点事儿   \n",
       "4  之前我们介绍了列表list与元组tuple这两种数据结构,其中列表list是我们用的最基本的...          南方的言   \n",
       "5  list是python语言的一种内置的数据类型.list是数学意义上的有序集合,也就是说li...       Jazmine   \n",
       "6  Python中关于 正则表达式的函数.re模块主要定义了9个常量、12个函数、1个异常,每个...       AI科技大本营   \n",
       "7  Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...          程序人生   \n",
       "8  Python 将成为每个开发者的标配.作者 | GitChat头图 | CSDN 下载自 V...          CSDN   \n",
       "9  前言本文适合有经验的程序员尽快进入Python世界.特别地,如果你掌握Java和Javasc...        python   \n",
       "\n",
       "           时间                                              公众号链接  \\\n",
       "0  1587360632  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "1  1587361546  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "2  1587361546  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "3  1587393888  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "4  1587382691  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "5  1587371010  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "6  1587379860  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "7  1586417179  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "8  1586520304  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "9  1586347353  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "\n",
       "                                                文章链接                格式化时间  \n",
       "0  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:30:32  \n",
       "1  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:45:46  \n",
       "2  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 05:45:46  \n",
       "3  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 14:44:48  \n",
       "4  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 11:38:11  \n",
       "5  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 08:23:30  \n",
       "6  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-20 10:51:00  \n",
       "7  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-09 07:26:19  \n",
       "8  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-10 12:05:04  \n",
       "9  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-08 12:02:33  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 2 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 2}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 2 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>别吹了!Python程序员正在消失! 资深CTO:你才发现?</td>\n",
       "      <td>@程序员你有没有感觉到,Python最近已经刷屏到爆炸了?细分析Python之所以刷屏,主要...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1585877968</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-03 01:39:28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Python是什么鬼?</td>\n",
       "      <td>Python正逐渐成为未来5~10年新一代毕业生、职场人的新一代“Office技能”.而它在...</td>\n",
       "      <td>日剧部屋</td>\n",
       "      <td>1584797897</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-03-21 13:38:17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>“Python简直万能!”拜托快醒醒!</td>\n",
       "      <td>在程序员中,一直流传着“Python除了不会生孩子,什么都会”的传说,Python真的是万能...</td>\n",
       "      <td>超级数学建模</td>\n",
       "      <td>1584455267</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-03-17 14:27:47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Python什么时候会被取代?</td>\n",
       "      <td>Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...</td>\n",
       "      <td>AI科技大本营</td>\n",
       "      <td>1586402894</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-09 03:28:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>手把手教你用 Python 绘制酷炫的桑基图!</td>\n",
       "      <td>Python手把手绘制桑基图动手之前,我们再次敲黑板,回顾桑基图组成要素的重点——节点、边和...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1585706777</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-01 02:06:17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>没错!Python杀死了Excel!</td>\n",
       "      <td>Python数据分析有多强大?举个栗子:用几行代码就能快速整理数据并出图:甚至可以编写合成多...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1584095406</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-03-13 10:30:06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Python 十大装 B 语法</td>\n",
       "      <td>作者 | 许向武责编 | 郭芮出品 | CSDN 博客Python 是一种代表简单思想的语言...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1572764522</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2019-11-03 07:02:02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>势头强劲的 Python PK 强大的 C++,究竟谁更胜一筹?</td>\n",
       "      <td>1.如果在Windows机器上用Windows编译器来编译代码,则会生成Windows机器代...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1580544534</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-02-01 08:08:54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Python 什么时候会被取代?</td>\n",
       "      <td>(给Python开发者加星标,提升Python技能)编译:CSDN-弯月,作者:Rhea M...</td>\n",
       "      <td>Python开发者</td>\n",
       "      <td>1586061444</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-04-05 04:37:24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>“一百万行 Python 代码对任何人都足够了”!</td>\n",
       "      <td>这种模棱两可的限制可能会带来严重后果,因此在Python中确定各种各样的限制是“Python...</td>\n",
       "      <td>CSDN</td>\n",
       "      <td>1578274924</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>https://weixin.sogou.com/link?url=dn9a_-gY295K...</td>\n",
       "      <td>2020-01-06 01:42:04</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 标题  \\\n",
       "0    别吹了!Python程序员正在消失! 资深CTO:你才发现?   \n",
       "1                       Python是什么鬼?   \n",
       "2               “Python简直万能!”拜托快醒醒!   \n",
       "3                   Python什么时候会被取代?   \n",
       "4           手把手教你用 Python 绘制酷炫的桑基图!   \n",
       "5                没错!Python杀死了Excel!   \n",
       "6                   Python 十大装 B 语法   \n",
       "7  势头强劲的 Python PK 强大的 C++,究竟谁更胜一筹?   \n",
       "8                  Python 什么时候会被取代?   \n",
       "9         “一百万行 Python 代码对任何人都足够了”!   \n",
       "\n",
       "                                                  摘要     source          时间  \\\n",
       "0  @程序员你有没有感觉到,Python最近已经刷屏到爆炸了?细分析Python之所以刷屏,主要...       CSDN  1585877968   \n",
       "1  Python正逐渐成为未来5~10年新一代毕业生、职场人的新一代“Office技能”.而它在...       日剧部屋  1584797897   \n",
       "2  在程序员中,一直流传着“Python除了不会生孩子,什么都会”的传说,Python真的是万能...     超级数学建模  1584455267   \n",
       "3  Python经过了几十年的努力才得到了编程社区的赏识.自2010年以来,Python得到了蓬...    AI科技大本营  1586402894   \n",
       "4  Python手把手绘制桑基图动手之前,我们再次敲黑板,回顾桑基图组成要素的重点——节点、边和...       CSDN  1585706777   \n",
       "5  Python数据分析有多强大?举个栗子:用几行代码就能快速整理数据并出图:甚至可以编写合成多...       CSDN  1584095406   \n",
       "6  作者 | 许向武责编 | 郭芮出品 | CSDN 博客Python 是一种代表简单思想的语言...       CSDN  1572764522   \n",
       "7  1.如果在Windows机器上用Windows编译器来编译代码,则会生成Windows机器代...       CSDN  1580544534   \n",
       "8  (给Python开发者加星标,提升Python技能)编译:CSDN-弯月,作者:Rhea M...  Python开发者  1586061444   \n",
       "9  这种模棱两可的限制可能会带来严重后果,因此在Python中确定各种各样的限制是“Python...       CSDN  1578274924   \n",
       "\n",
       "                                               公众号链接  \\\n",
       "0  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "1  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "2  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "3  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "4  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "5  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "6  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "7  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "8  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "9  https://weixin.sogou.com/link?url=dn9a_-gY295K...   \n",
       "\n",
       "                                                文章链接                格式化时间  \n",
       "0  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-03 01:39:28  \n",
       "1  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-03-21 13:38:17  \n",
       "2  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-03-17 14:27:47  \n",
       "3  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-09 03:28:14  \n",
       "4  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-01 02:06:17  \n",
       "5  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-03-13 10:30:06  \n",
       "6  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2019-11-03 07:02:02  \n",
       "7  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-02-01 08:08:54  \n",
       "8  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-04-05 04:37:24  \n",
       "9  https://weixin.sogou.com/link?url=dn9a_-gY295K...  2020-01-06 01:42:04  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 3 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 3}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 3 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 4 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 4}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 4 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 5 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 5}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 5 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 6 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 6}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 6 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 7 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 7}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 7 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 8 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 8}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 8 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第 9 页\n",
      "payload: {'query': 'python', 'type': '2', 'page': 9}\n",
      "url: https://weixin.sogou.com/weixin\n",
      "第 9 页 的Dataframe\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdz9hAFZHvOAvrB3fLsZY8_H3d-eeqBTdmCdFb_D0ExkjR0RWyTdsC9ffD6FLdcrCzfsv9agUQiWyD-fhItqiT8ws4ALjXNzsmHHzkXy3IF9BEcRnxbQJATdmRTpLLTNgHY&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzM1N3sg6-MGMs4Ovzv0sOdV6iNSk94nbViiSSJhj5RDOB07es2XIcPyyXi_McJDQhaXt1_F979mkpTPofR_EpXKBrntIaygYIHmgTsYMopXifr4EuC_HGCaUiiWOv1GPM&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzm8v_vPQGNoDxM0PrhpThWcm62a7X6fMCWJls5iOw8XEnJzF3NCDwvl-PLobqeFZrQUXektIerUoX9qm4Vu8vANAfrapy-vrww9sSjbU7RS8ophu08gnScqUiiWOv1GPM&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzlQCIubVzt3MvkEeH5UEgji3TGguOw4lg8KTPIx5DO4mMYAxfSMj1Zph7SE01eNr6q8lxw7oXEFT7ftrSHZlUs7FMZbjGEDOMLsJx4Eyej2DAJDzTAmqekuO00efWrWmm&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzb2AvcLFS9mIjb5aelwKIsx6O1qUXSRPIcoBaidJrmk6zKBi7fJqweVYd4uGhb2kwVNGMgRVF9bdEkZnAIKHWmkAUGHL0Z5yLg0MYi0Z8kfgxSymK0fI5TOO00efWrWmm&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdz0Z4DBn4Zh0dhZ1RLwSLiLgu4t3bHnxkfGKRCJqwJ0Wxf-EelY8fdwft0vKg9oP5CgT3564Xworvnta86mt-GKPPiQhqeXmx-byBKG8ynkXjGUZ0rbYZdvOO00efWrWmm&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzhiXxtXO9EWIxSPw0jjYSGEjnjJsf7swwALg6NXYasB9O7uNXIBeupB2XH4_Q6XnJSHQ4IkKSlqd-P580XxeujHqqrTvJ04Y4ECEfsWb5sppNbML6WdbpSmRTpLLTNgHY&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzeLxXplXAcuNuVuNPiFqscsKWDWntqkEi14zy27r5NbdFls1_OnGoFix4ZDKkBJOx-2Ls84MFeMX_AicIp_zOvGeBVo14B27snMMylUfSonuiTfR-9a0SYOO00efWrWmm&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPtPm6d1a3lJPAwvDqyjOWdzKhkrIQmebKHlYhHkd3mspLTPGUm0OolGErK4Sq5xclsY1-mWDU6MeaOHX5_kBUMNCHXg-ceTOVHy5w8DevywTdoLr6iiBcp3nkC_8kqs2OspTVGiDEygLOO00efWrWmm&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPuvEEFloB-p5QwvDqyjOWdzeLxXplXAcuNuVuNPiFqscsKWDWntqkEi14zy27r5NbdFls1_OnGoFix4ZDKkBJOx-2Ls84MFeMX_AicIp_zOvEGNBkPZzKpR0sHIHoGbAsOUsPF0kroMS24OZCnxixtX&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPuvEEFloB-p5QwvDqyjOWdz1Y5gCKRmba7CCrq7rLcYrkLtasrdJUHF_KvLC3_3QpdpvCEITjwvRuiOT8oDCtE70yJpZPOSJRFJ5DqkZqNoPgXZ075PkZmF5Ttm-jbadzXcYd6FR_Aogm4OZCnxixtX&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPuvEEFloB-p5QwvDqyjOWdzO83OgHBo6AQbxPIWco6SPFNh2LnlbLn4ipiaNDz13Ucp1qCLFEfEfe6NnAXB8eJ8G9QdvULMpJAQYRvZYDHYX7CydKJVKT18owcrTXKbDHgp8Pn6cDz6dqUiiWOv1GPM&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPuvEEFloB-p5QwvDqyjOWdz0Z4DBn4Zh0dhZ1RLwSLiLgu4t3bHnxkfGKRCJqwJ0Wxf-EelY8fdwft0vKg9oP5CgT3564Xworvnta86mt-GKPgP6D47Avo3WySRHyYtJFUPV6Z0HKXwdW4OZCnxixtX&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6EzDJysI4ql5MPrOUp16838dGRMI7NnPq8QlcBx3-EPuvEEFloB-p5QwvDqyjOWdzIo9Az8SqXK3_A_CK13Kujd32TV12-JywQ_RE-jaGdd4j0_G0k9prrhtIzBM9jmwPAZ8WJ4hEpH-xyqdCb_E5StGEFmGx-vPF7RML9Q-pI7IfHLh9-rb-SOO00efWrWmm&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9sa9322q9iwoXlVogCNv9kdCTMhnIA5C6kO-j7GSNZusPmj_Ffg9QZ6iea3AurkGhsp3Y9gBxJ6AT_rFRfHR0slW3NIUfETMUv3CbRKWLPzb64YH_ZIGu9LYjZTeEKuGf2NNnu4Yd65q7hfTKQ_zLNq_V-_h9TgDUOFn4gdzsVsQ6Ebq8fk9diw..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPAlEi-XVqDJRFsV511DBFu_X-XOWR7A_CjT3Ada9Fj16pTKf5AN2uGWkQVVQy8ArueP3VGhnvoBgOVuRCpkULG5mp6yCKDk-64oxcYuw-VyuooGk6ZDFdn_RtmyIGw2VAg..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9mQGXVT9-NdcfcqnvdeRq69lL-zYKIRp4yStU1L3FOXljFEAkQLLZPGzavUQGKBYFsQuP6J8D081OV7Sl1W7W_YW2WGjZprfjtTcaP1hswzl7RtVsGWxO04GJF80IFL4UYRd1KjgS-m6OhUMXMu2qFO5Gut3V3J17uO4fjL9cLsgGX_iHL9MadA..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd96dwhnbWU0yClHSlDOyUbbo2qNacVDPOSWoLcY0WBpOT6gQ5R0zBvweBv0A5TiDRe7VMCjKZiEPiaIQIj0cuL8DlqD4n7opBHI4QrIzTYvrh77MTbH_kpKE0kyxjwOuItI8AFWhi8dZe4meUrCXdpIqL_QZqg6zzCGMIh1q7xL0efxjh3za6jWA..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9XMuNn5RgVH8r36t3LXSCZS2yJkDubNmfQGTreS1IGAeMjF4mBqH1_cCI8IfNb6Ibsr_V5qPFOozbjJcWKW2ltI_k_bjxX9qzRO0P2WbbWFCNMw4Tv0Un4aQ_gj8hR4leSYj-v1pFuKWQ5W-C0AvFfyhQpkWUEszh-m3I2Sdn0Ex5Nu7CnoSqqg..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9UsvmZKcSb2Yf9RZSY0uhDlB6zHV-tK1TewpXeXdKYuDXN-nz_USDbpBjxF5XH3UGTtqDN6neGmb8VCUk2SrGQgqSOG1sOGKFOZ-_GqlGv41b8GLRYcDIcLTLwI5csbTdPyT0hx1-SkxLxosMOh9hSxT3hnn65e5SLX_2XMJfSU1Ae0f8bRARvQ..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9g8AsxrKPL2e7a0n0BlZE8KyYLXZjGDK6EpYI-xAU-9Z1mzGePdh3xmvQtXN9VPPo0xL425irIUP9QdiMLBQrP3W1P0Aors8jaBbUtA1inmVYEjxKsZIvNTOw7vCqUvoNb6uJBVg_QpsJNOOnrTXMKvJ1akeA4LofYArOuVa1rFk6Ebq8fk9diw..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9OPAbTa7ylcd6m6bjESu65yv8kd6Bdpw5P8-1ub1qZQ3pZQpkdkvpfYnmxv3jiN-3-4tRfK2qBlOKdJHMPX25BrzGk1gFH2tMAQkoEPAoxhqxBwmtLb4mj0x_IA8tE_V6q6fLaVANGOdS9VT-MK2a-F2sa_z2tsUf_u3bZ1DJlyLwdVqCwyPdzA..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQcZfYjCRCQIl-Kz1UXTIiGNm8ddHOVX1P-lZWudkG7Dw0UpN3OmNzkYiHXrmRWT6MF3JWJC8ISVMS3bHGOpgWylTsT0SAOapnuIR0HyQvxehCeMtLo6icjk6Ebq8fk9diw..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjy31fqULH03s4gV8M3bpyKVqXa8Fplpd9guHGcmoYYXs4hL1GjGGGagVMTXK7aCKi0Ih7F7AMNW2Uh0xwJNF5bz8YKoh2pPEQMR-FvFergQVKq2ngJMm1t90u3h3qopLqn_YyHpYcPAFZP6ye6XLDVDKmagBT3BlwY1QrntgnJXMQ0OIFbBdt2I0wBzIL8GDho6yWnW_WZjb2CsG6-xMgzQ..&type=2&query=python&token=3AF6A7B768F7A4AEDADF7963C3068635DAAC8EEB5E9DB810' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQUwEisVgH6fMLAvolXupx9nbqPuXSaK-ee1a8hCdE6krAH_r8eI7Dutk5oB_0-JhvXAgiXWxK437EieJKkZ_5mX0acxnDCLynsfXKCYYmtctf-ODyshJoFLf3q8uRDTfkw..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9NMzEMSAenD-kk8lp51CTwjk57xwYRcFYAhVg4tBwg7mmTRNX4hC6DyIbIe85TuZ512aB3xEBnsee9AtU-Ptes6IqacsJuJrsGQtQrdTwzXD4SB0HLoSihhMZtSZ-gx3NYmr5XlzgF0ZWS-mis0VT-m-VK1AmzRwaUHT6ZSTinedj32-j2KiwUw..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9Egv0O1GXWwoLhYIQBFuxK4mbbvCeaXEGOCfPjx3gyPVuIClWXzjof8xZGTkvlhfTho-5hAWtjTn356QXY1mYeKMzjfMA3Dzj006UxNAL0b2YTe2v3Xm1zqAj3c2x0Nq8-RdiYZQuIxHaV2nnKvr6CNcpKss1mN5WFJTHR62hykP0OK9DLfgmPA..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9g8AsxrKPL2e7a0n0BlZE8KyYLXZjGDK6EpYI-xAU-9Z1mzGePdh3xg02jCDJ2tgWVPgJgwH-_TemMDCL7hJUvQmt7XQ7O13JD6WlgGE3QZQW-2bUgEmXh7fkrg38E6BhTZE44UEfPggHSR0NUld1M9OeUb1mhH4q4_wjsnIL7h15Nu7CnoSqqg..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQSEkDLb-HXtsRQ4ImldzOfkzsdyqkXca2NInpD1RW60x_0VOO32XbzurgxNfdAZeOg2e3h1Odtib1UnCzHFbQ5PGkZyarEc33iDUSM1FYDJ6ifZiMUe9p0QGX_iHL9MadA..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQcafCin4zPQAQ3z7vFquh5JNJNqYmpmbOgpOuBKbIo-T5Ts1obY_CQGg6Jud_oHKGfc6VhK_5xbMH8XMspQTyLA4CHaKKccnO9ABAoiIMepxXtkk4lS4GEXvzHZXxeLdyg..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQchRdoTs6XQaO-LjtTrOUfPtDnaplJeQUNP27UUTkkZJZ8kGzDZVd3xss1xIWVKGShtTMr94OSnd26b15re6ntKdhaUHwj6QPwaAGJK-VN7Ds9e3HQzC9r7FcvUoAZZH7Q..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQVH3ItgHeFmsqJ3Y-5ziNBgsdEk1jODQA_79ZZfLfV-zGVqCbYuY41yvC50j5beK91qKuAdI9XASMaJhDp9ddPWX7kKKQTiz6PP9tTcYnxDykr7nAuEeO0rS-e4Yz84xMA..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9Iin1EtoOKMIuGBRr6By7dA2bZnUF6Hs8cgep4gt0ZyiunsfVuEVEtVxe3z9zDW9gkrpd1tx7senHCbM84aTTRzGkS8Ytnok-yr1ku69CYsQHhKhmTCIAvTmdhpJwqgLEad0Hh3ByJxZuz9_hdP9-ZqWrwPzmqiqMwaXcomaB_AJAe0f8bRARvQ..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n",
      "D:\\anaconda\\lib\\site-packages\\xlsxwriter\\worksheet.py:915: UserWarning: Ignoring URL 'https://weixin.sogou.com/link?url=dn9a_-gY295K0Rci_xozVXfdMkSQTLW6cwJThYulHEtVjXrGTiVgS8HGqhNZfMkjxZC0-Ypki7g4gV8M3bpyKVqXa8Fplpd9iuN5qV9dZywXtLWFBI5NU5hA2QjchCJBtMOR4czJ5x82s8WJ_9rLQb0e1HmrvqxX9emD-kjRmVaXDK9OdFFIkKjLZiQg6Hry7XcButmS-W2x9uFMkKfkxmDP72v8ydON6-NLaKAs1NNgfpioLNXcN1i3_glfz-LW03SwR2OdKqhflztgI7RZ1g..&type=2&query=python&token=3AF6BC3C68F7A4AEDADF7963C3068635DAAC8EEB5E9DB816' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS\n",
      "  force_unicode(url))\n"
     ]
    }
   ],
   "source": [
    "session = HTMLSession()\n",
    "def request_sougou_weixin(url,params):\n",
    "    r = session.get( url, params = payload, ) \n",
    "    主要元素 =  r.html.xpath( '//ul[@class=\"news-list\"]/li')\n",
    "\n",
    "    dict_xpaths = {\n",
    "        'text':{\n",
    "            'source':'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/a/text()',\n",
    "            '时间':'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/@t',       \n",
    "        },\n",
    "        'text_content':{\n",
    "            '标题':'//div[contains(@class,\"txt-box\")]/h3/a',\n",
    "            '摘要':'//div[contains(@class,\"txt-box\")]/p'\n",
    "        },\n",
    "        'href':{\n",
    "            \"公众号链接\":'//div[contains(@class,\"txt-box\")]/div[@class=\"s-p\"]/a/@href',\n",
    "            \"文章链接\":'//div[contains(@class,\"txt-box\")]/h3/a/@href',\n",
    "        }\n",
    "    }\n",
    "\n",
    "#nlist不能放在循环里面，因为如果放在里面，添加的数据就会被后面的替代，最后得到只是最后一个循环的数据，变量所放位置和返回数据的位置格外中重要\n",
    "    def get_e_text_content(_xpath_):\n",
    "        nlist= list()\n",
    "        for e in 主要元素:\n",
    "            nlist.append(e.xpath(_xpath_)[0].lxml.text_content()) # .lxml.text_content(拼接标题)\n",
    "        return(nlist)\n",
    "    \n",
    "    def get_e_text(_xpath_):\n",
    "        nlist = list()\n",
    "        for e in 主要元素:\n",
    "            for x in e.xpath(_xpath_):\n",
    "                nlist.append(\"\".join([x.strip() if type(x) is str else x.text.strip()]))\n",
    "        return(nlist)\n",
    "        \n",
    "    def get_e_href(_xpath_):\n",
    "        nlist=list()\n",
    "        for e in 主要元素:\n",
    "            for item in e.xpath(_xpath_):\n",
    "                nlist.append(\"https://weixin.sogou.com\"+item)\n",
    "        return(nlist)  #原来缩进决定了遍历第一个还是全部的内容，谨记！\n",
    "\n",
    "    数据字典 = dict()\n",
    "    数据字典 = {k:get_e_text_content(v) for k,v in dict_xpaths['text_content'].items()}\n",
    "\n",
    "    数据字典.update({k:get_e_text(v) for k,v in dict_xpaths['text'].items()})\n",
    "    数据字典.update({k:get_e_href(v) for k,v in dict_xpaths['href'].items()})\n",
    "\n",
    "    数据 = pd.DataFrame(数据字典)\n",
    "    数据 = 数据.assign(\n",
    "        格式化时间 = lambda x: pd.to_datetime(x[\"时间\"], unit='s').dt.strftime('%Y-%m-%d %H:%M:%S')\n",
    "    )\n",
    "    return(数据)\n",
    "\n",
    "\n",
    "url = \"https://weixin.sogou.com/weixin\"\n",
    "\n",
    "\n",
    "list_df=[]\n",
    "for i in range(1,10):\n",
    "    print(\"第\",i,\"页\")\n",
    "    payload = {\n",
    "        \"query\":\"python\",\n",
    "        \"type\":\"2\",\n",
    "        \"page\":i\n",
    "\n",
    "    } \n",
    "    print(\"payload:\",payload)\n",
    "    print(\"url:\",url)\n",
    "    time.sleep(5)\n",
    "    df = request_sougou_weixin(url,params=payload)\n",
    "    print(\"第\",i,\"页\",\"的Dataframe\")\n",
    "    display(df)\n",
    "    \n",
    "    df.to_csv(\"web_week05_sougou_weixin_{key}_{k}.tsv\".format(key=\"python\", k=i), sep=\"\\t\", encoding=\"utf8\")\n",
    "        \n",
    "    df = df.assign (query = \"python\")  # 区分  query   \n",
    "    df = df.assign (page = i)  # 区分  page    \n",
    "    list_df.append(df)\n",
    "    \n",
    "\n",
    "df_all = pd.concat(list_df).reset_index()\n",
    "df_all.index.name = '序'\n",
    "\n",
    "df_all.to_excel(\"web_week05_sougou_weixin_翻页_5.xlsx\",\\\n",
    "                sheet_name=\"_\".join(\"python\"))\n",
    "# 预估时间: 4*5秒*10 =200\n",
    "# 预估数量: 4*40*10 =1600"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'query': ['python'], 'type': ['2'], 'page': ['1'], 'ie': ['utf8']}\n",
      "  scheme netloc path params                                query fragment\n",
      "0                             query=python&type=2&page=2&ie=utf8         \n",
      "1                             query=python&type=2&page=3&ie=utf8         \n",
      "2                             query=python&type=2&page=4&ie=utf8         \n",
      "3                             query=python&type=2&page=5&ie=utf8         \n",
      "4                             query=python&type=2&page=6&ie=utf8         \n",
      "5                             query=python&type=2&page=7&ie=utf8         \n",
      "6                             query=python&type=2&page=8&ie=utf8         \n",
      "7                             query=python&type=2&page=9&ie=utf8         \n",
      "8                            query=python&type=2&page=10&ie=utf8         \n",
      "9                             query=python&type=2&page=2&ie=utf8         \n",
      "python 10\n",
      "参数_query_X_page {1: {'query': ['python'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}, 2: {'query': ['python'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}, 3: {'query': ['python'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}, 4: {'query': ['python'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}, 5: {'query': ['python'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}, 6: {'query': ['python'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}, 7: {'query': ['python'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}, 8: {'query': ['python'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}, 9: {'query': ['python'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}}\n",
      "payload {'query': ['python'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['python'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'query': ['UX'], 'type': ['2'], 'page': ['1'], 'ie': ['utf8']}\n",
      "  scheme netloc path params                                query fragment\n",
      "0                             query=python&type=2&page=2&ie=utf8         \n",
      "1                             query=python&type=2&page=3&ie=utf8         \n",
      "2                             query=python&type=2&page=4&ie=utf8         \n",
      "3                             query=python&type=2&page=5&ie=utf8         \n",
      "4                             query=python&type=2&page=6&ie=utf8         \n",
      "5                             query=python&type=2&page=7&ie=utf8         \n",
      "6                             query=python&type=2&page=8&ie=utf8         \n",
      "7                             query=python&type=2&page=9&ie=utf8         \n",
      "8                            query=python&type=2&page=10&ie=utf8         \n",
      "9                             query=python&type=2&page=2&ie=utf8         \n",
      "UX 10\n",
      "参数_query_X_page {1: {'query': ['UX'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}, 2: {'query': ['UX'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}, 3: {'query': ['UX'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}, 4: {'query': ['UX'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}, 5: {'query': ['UX'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}, 6: {'query': ['UX'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}, 7: {'query': ['UX'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}, 8: {'query': ['UX'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}, 9: {'query': ['UX'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}}\n",
      "payload {'query': ['UX'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['UX'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'query': ['吴磊'], 'type': ['2'], 'page': ['1'], 'ie': ['utf8']}\n",
      "  scheme netloc path params                                query fragment\n",
      "0                             query=python&type=2&page=2&ie=utf8         \n",
      "1                             query=python&type=2&page=3&ie=utf8         \n",
      "2                             query=python&type=2&page=4&ie=utf8         \n",
      "3                             query=python&type=2&page=5&ie=utf8         \n",
      "4                             query=python&type=2&page=6&ie=utf8         \n",
      "5                             query=python&type=2&page=7&ie=utf8         \n",
      "6                             query=python&type=2&page=8&ie=utf8         \n",
      "7                             query=python&type=2&page=9&ie=utf8         \n",
      "8                            query=python&type=2&page=10&ie=utf8         \n",
      "9                             query=python&type=2&page=2&ie=utf8         \n",
      "吴磊 10\n",
      "参数_query_X_page {1: {'query': ['吴磊'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}, 2: {'query': ['吴磊'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}, 3: {'query': ['吴磊'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}, 4: {'query': ['吴磊'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}, 5: {'query': ['吴磊'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}, 6: {'query': ['吴磊'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}, 7: {'query': ['吴磊'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}, 8: {'query': ['吴磊'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}, 9: {'query': ['吴磊'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}}\n",
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['吴磊'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'query': ['刀剑神域'], 'type': ['2'], 'page': ['1'], 'ie': ['utf8']}\n",
      "  scheme netloc path params                                query fragment\n",
      "0                             query=python&type=2&page=2&ie=utf8         \n",
      "1                             query=python&type=2&page=3&ie=utf8         \n",
      "2                             query=python&type=2&page=4&ie=utf8         \n",
      "3                             query=python&type=2&page=5&ie=utf8         \n",
      "4                             query=python&type=2&page=6&ie=utf8         \n",
      "5                             query=python&type=2&page=7&ie=utf8         \n",
      "6                             query=python&type=2&page=8&ie=utf8         \n",
      "7                             query=python&type=2&page=9&ie=utf8         \n",
      "8                            query=python&type=2&page=10&ie=utf8         \n",
      "9                             query=python&type=2&page=2&ie=utf8         \n",
      "刀剑神域 10\n",
      "参数_query_X_page {1: {'query': ['刀剑神域'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}, 2: {'query': ['刀剑神域'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}, 3: {'query': ['刀剑神域'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}, 4: {'query': ['刀剑神域'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}, 5: {'query': ['刀剑神域'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}, 6: {'query': ['刀剑神域'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}, 7: {'query': ['刀剑神域'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}, 8: {'query': ['刀剑神域'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}, 9: {'query': ['刀剑神域'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}}\n",
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [1], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [2], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [3], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [4], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [5], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [6], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [7], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [8], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "payload {'query': ['刀剑神域'], 'type': ['2'], 'page': [9], 'ie': ['utf8']}\n",
      "https://weixin.sogou.com/weixin\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>摘要</th>\n",
       "      <th>source</th>\n",
       "      <th>时间</th>\n",
       "      <th>公众号链接</th>\n",
       "      <th>文章链接</th>\n",
       "      <th>格式化时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [标题, 摘要, source, 时间, 公众号链接, 文章链接, 格式化时间]\n",
       "Index: []"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 3min 13s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "# C-1 多个页面+多个关键词\n",
    "import time\n",
    "from random import random\n",
    "\n",
    "url = \"https://weixin.sogou.com/weixin\"\n",
    "xpath_a = '//div[@class=\"p-fy\"]/a[starts-with(@href,\"?query\")]'\n",
    "# 多界面（不同的内容（分类、关键词））多页面（翻页）\n",
    "query = ['python','UX','吴磊','刀剑神域']\n",
    "list_df = list()\n",
    "\n",
    "## 第一页试探有多长的页面\n",
    "for key in query:\n",
    "    payload = 参数模板生成(query=[key], page=['1'])\n",
    "    print(payload)\n",
    "    \n",
    "    df = request_sougou_weixin(url,params = payload)\n",
    "    #href_list = [x.xpath('//@href')[0] for x in r.html.xpath(xpath_a)]\n",
    "    href_list=list()\n",
    "    for x in r.html.xpath(xpath_a):\n",
    "        href_list.append(x.xpath('//@href')[0])\n",
    "    df = pd.DataFrame([ urlparse(x) for x in href_list])\n",
    "    print(df)\n",
    "          \n",
    "    df_qs = pd.DataFrame([{k:v[0] for k,v in parse_qs(x).items()} for x in df['query']])\n",
    "    df_qs = df_qs.assign (page_int=df_qs.page.astype(int)) # 变成整数\n",
    "    长度 = df_qs.page_int.max()\n",
    "    参数_query_X_page = { i:参数模板生成(page = [i],query = [key]) for i in range(df_qs.page_int.min()-1,长度)}\n",
    "    #print (参数_query_X_page)\n",
    "    print (key,长度)\n",
    "    print(\"参数_query_X_page\",参数_query_X_page)\n",
    "    \n",
    "    for k,v in 参数_query_X_page.items():\n",
    "        payload = v\n",
    "        print(\"payload\",payload)\n",
    "        print(url)\n",
    "        df = request_sougou_weixin( url, params = payload)\n",
    "        \n",
    "        time.sleep(3+4*random())  #放慢脚步 3-7秒, 平均约5秒\n",
    "        # 备份\n",
    "        display(df)\n",
    "        df.to_csv(\"web_week05_sougou_weixin_{key}_{k}.tsv\"\\\n",
    "                  .format(key=key, k=k), sep=\"\\t\", encoding=\"utf8\")\n",
    "        \n",
    "        df = df.assign (query = key)  # 区分  keyword    \n",
    "        df = df.assign (page = k)  # 区分  page    \n",
    "        list_df.append(df)\n",
    "        \n",
    "df_all = pd.concat(list_df).reset_index()\n",
    "df_all.index.name = '序'\n",
    "\n",
    "df_all.to_excel(\"web_week05_sougou_weixin_翻页_5.xlsx\",\\\n",
    "                sheet_name=\"_\".join(query))\n",
    "# 预估时间: 4*5秒*10 =200\n",
    "# 预估数量: 4*40*10 =1600"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
